{extend name="common/zoushi_index" /}
{block name="body"}
<style type="text/css">
#chartsDiv_1 {
  zoom: 76%
}
.trend-content1 .trend-bg-average td{
	width: 5%;
}
.trend-content1 .trend-bg-average td:first-child{
	width: 20% !important;
}
</style>

	<div id="wrapper_1" class="scorllmain-content scorllmain-Beet nobottom_bar" style="margin-top:45px; margin-bottom:65px"> 
   <div class="sub_ScorllCont" style="height: 100%;"> 
  	<div style="width:100%; float:left;">
	
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_1" onClick="weizhigb(1);">第一位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_2" onClick="weizhigb(2);">第二位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_3" onClick="weizhigb(3);">第三位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_4" onClick="weizhigb(4);">第四位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_5" onClick="weizhigb(5);">第五位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_6" onClick="weizhigb(6);">第六位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_7" onClick="weizhigb(7);">第七位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_8" onClick="weizhigb(8);">第八位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_9" onClick="weizhigb(9);">第九位</div>
	<div style="color: #e53120; width:20%; height:30px; text-align:center; line-height:30px; border:#696969 solid 1px; float:left; margin-top:5px; display:none" id="qiu_10" onClick="weizhigb(10);">第十位</div>
	

	</div>
    <div id="chartsDiv_1" class="trend-content" style="padding-bottom: 144px;"> 
     <table id="trend_table_1" cellpadding="0" cellspacing="0">
  
     </table> 
     

	 
	 </div>
	 <div class="trend-content trend-content1" style="position: fixed;bottom: 40px;width: 100%;z-index:100">
	 {if condition="$game_id neq '9'"} 
	 <table id="trend_js" cellpadding="0" cellspacing="0">
  
     </table>
     {/if} 
     </div>
    </div> 
  
</div>
<input type="hidden" value="{:input('get.game_id')}" id="czid">
<input type="hidden" value="{:input('get.hmq') ? input('get.hmq') : 1}" id="countuu">
 <script>
 var trend_title = '定位胆';
    try{
        isLogin = false;
        }catch(e){console.log(e);}
</script> 
  <script>
$(function(){
    		
			
			
			var czipd=document.getElementById("czid").value;
			if(czipd=="1" || czipd=="62" || czipd=="2" || czipd=="3" || czipd=="6" || czipd=="8" || czipd=="11" || czipd=="12" || czipd=="52" || czipd=="53" || czipd=="54"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
			
			}
			
			if(czipd=="4" || czipd=="56" || czipd=="61" || czipd=="63"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
				$('#qiu_6').show();
				$('#qiu_7').show();
				$('#qiu_8').show();
				$('#qiu_9').show();
				$('#qiu_10').show();
			
			}
			
			if(czipd=="5" || czipd=="48" || czipd=="7" || czipd=="36" || czipd=="37" || czipd=="38" || czipd=="39" || czipd=="40" || czipd=="41" || czipd=="42" || czipd=="43" || czipd=="44" || czipd=="45" || czipd=="46" || czipd=="47" || czipd=="48" || czipd=="57" || czipd=="10" || czipd=="72"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
			
			}
			
			if(czipd=="13" || czipd=="14" || czipd=="15" || czipd=="16" || czipd=="17" || czipd=="18" || czipd=="19" || czipd=="20" || czipd=="21" || czipd=="22" || czipd=="23" || czipd=="24" || czipd=="25" || czipd=="26" || czipd=="27" || czipd=="28" || czipd=="29" || czipd=="31" || czipd=="32" || czipd=="33" || czipd=="34" || czipd=="35" || czipd=="58"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
			
			}
			if(czipd=="49" || czipd=="59"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
				$('#qiu_6').show();
				$('#qiu_7').show();
				$('#qiu_8').show();
			
			}
			if(czipd=="51"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
				$('#qiu_6').show();
				$('#qiu_7').show();
			
			}
			if(czipd=="9"){
				
				$('#qiu_1').show();
				$('#qiu_2').show();
				$('#qiu_3').show();
				$('#qiu_4').show();
				$('#qiu_5').show();
				$('#qiu_6').show();
				$('#qiu_7').show();
			
			}
		
			 
			
    	});
	function weizhigb(wzs){
	
	var dusid=document.getElementById("czid").value;
	
	this.location.replace('trendDetails?game_id='+dusid+'&hmq='+wzs);
	
	}
    </script> 
  <script>
        function loaded(){}//空实现
        //document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); //uc浏览器滑动
    </script> 
  <script>
    //对象转数组
    function obj2arr(obj) {
        var arr = [];
        for(var item in obj){
            arr.push(obj[item]);
        }
        return arr;
    }
</script> 
  <script>
    function drawLine(hmq) {
        var cvList = $('#chartsDiv_'+hmq+' canvas');
        for (var i = 0; i < cvList.length; i++) {
            var tmpCv = cvList[i];
            var width = $(tmpCv).width();
            var height = $(tmpCv).height();
            var direc = $(tmpCv).data('direc_'+hmq);
            width = (width == undefined) ? 0 : parseInt(width);
            height = (height == undefined) ? 0 : parseInt(height);
            var context=tmpCv.getContext('2d');
			context.beginPath();
            if (direc == 1) {
                context.moveTo(0,0);
                context.lineTo(width, height);
            } else {
                context.moveTo(0, height);
                context.lineTo(width,0);
            }
		if(height<37){
		
		context.strokeStyle = '#FF0000';
        context.stroke();
		
		}
        
        }
		
    }
</script> 
<script>
    $(function() {
        $('li.game_li_'+trendGid).click();
        //getTrendData();
    });
</script> 	
<script>
    trendGid = 1;
    trendCount = 20;
    trendPos = 1;
	var czipd=document.getElementById("czid").value;
	var countuu=document.getElementById("countuu").value;
	noStr = '0|1|2|3|4|5|6|7|8|9';
	if(czipd=="1" || czipd=="2" || czipd=="3" || czipd=="6" || czipd=="8" || czipd=="11" || czipd=="12" || czipd=="52" || czipd=="53" || czipd=="54" || czipd=="62"){
		noStr = '0|1|2|3|4|5|6|7|8|9';
	}
	if(czipd=="4" || czipd=="56" || czipd=="61" || czipd=="62"){
		noStr = '1|2|3|4|5|6|7|8|9|10';
	}
	if(czipd=="5" || czipd=="7" || czipd=="10"){
		noStr = '0|1|2|3|4|5|6|7|8|9';
	}
	if(czipd=="48" || czipd=="36" || czipd=="37" || czipd=="38" || czipd=="39" || czipd=="40" || czipd=="41" || czipd=="42" || czipd=="43" || czipd=="44" || czipd=="45" || czipd=="46" || czipd=="47" || czipd=="48" || czipd=="57" || czipd=="72"){
		noStr = '1|2|3|4|5|6';
	}
	if(czipd=="13" || czipd=="14" || czipd=="15" || czipd=="16" || czipd=="17" || czipd=="18" || czipd=="19" || czipd=="20" || czipd=="21" || czipd=="22" || czipd=="23" || czipd=="24" || czipd=="25" || czipd=="26" || czipd=="27" || czipd=="28" || czipd=="29" || czipd=="31" || czipd=="32" || czipd=="33" || czipd=="34" || czipd=="35" || czipd=="58"){
		noStr = '01|02|03|04|05|06|07|08|09|10|11';
	}
	if(czipd=="49" || czipd=="59"){
		noStr = '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20';
	}
	if(czipd=="51"){
		noStr = '0|1|2|3|4|5|6|7|8|9';
	}
	if(czipd=="9"){
		noStr = '0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49';
	}

	
	
	
	getTrendData();
	
    function getTrendData() {
        if (trendGid == null || trendGid == undefined || trendGid == '') {
            trendGid = 1;
        }
		
		
        $.ajax({
            url: '/index/lottery/trendIframe?czid='+czipd+'&hmq='+countuu,
            type: 'POST',
            dataType: 'json',
            data: {
                'gid' : trendGid,
                'count' : trendCount,
                'pos' : trendPos
            },
            timeout: 30000,
            success: function (data) {
                if (data.Result == false) {
                    msgAlert(data.Desc);
                    reLogin(data.Desc);
                    return false;
                }
                //福体彩
				
                var headHtml = '';
                var tbHtml = '';
                var noArr = noStr.split('|');
                var noLen = noArr.length;
			
					
						headHtml = '<tr class="trend-titbg">'+'<th>开奖期数</th>';					
					
					for (var i = 0; i < noLen; i++) {
						headHtml += '<th>'+ noArr[i] +'</th>';
					}
					headHtml += '</tr>';
			
                
                for (var i = 0; i < data.RecordCount; i++) {
                    var tmpOpenNum = data.Records[i].iOpenNum;
                    var clsBg = (i % 2 == 1) ? 'class="trend-bg"' : '';
                    tbHtml += '<tr ' + clsBg + '>';
					if(countuu>0){
					var qishucd=data.Records[i].sGamePeriod.length
					if(qishucd<8){
						var xhsuchs=8-qishucd;
						var lsjrxx="";
						for(var r=1; r<=xhsuchs;r++){
							lsjrxx+="&nbsp;";
						}
						data.Records[i].sGamePeriod=data.Records[i].sGamePeriod+lsjrxx;
					}
					
					tbHtml += '<td>'+data.Records[i].sGamePeriod+'</td>';
					
					}
                    
                    if (data.Records[i].iYL0 != undefined) {
                        tbHtml += '<td>'+((tmpOpenNum == 0) ? '<span class="cur">':'')+data.Records[i].iYL0+((tmpOpenNum == 0) ? '</span>':'')+'</td>';
                    }
                    tbHtml += '<td>'+((tmpOpenNum == 1) ? '<span class="cur">1':data.Records[i].iYL1)+((tmpOpenNum == 1) ? '</span>':'')+'</td>';
                    tbHtml += '<td>'+((tmpOpenNum == 2) ? '<span class="cur">2':data.Records[i].iYL2)+((tmpOpenNum == 2) ? '</span>':'')+'</td>';
                    tbHtml += '<td>'+((tmpOpenNum == 3) ? '<span class="cur">3':data.Records[i].iYL3)+((tmpOpenNum == 3) ? '</span>':'')+'</td>';
                    tbHtml += '<td>'+((tmpOpenNum == 4) ? '<span class="cur">4':data.Records[i].iYL4)+((tmpOpenNum == 4) ? '</span>':'')+'</td>';
                    tbHtml += '<td>'+((tmpOpenNum == 5) ? '<span class="cur">5':data.Records[i].iYL5)+((tmpOpenNum == 5) ? '</span>':'')+'</td>';
                    tbHtml += '<td>'+((tmpOpenNum == 6) ? '<span class="cur">6':data.Records[i].iYL6)+((tmpOpenNum == 6) ? '</span>':'')+'</td>';
                    
                    for(v=7;v<51;v++){
                    	 var tmp = "iYL"+v;
                    	 if (data.Records[i][tmp] != undefined) {
                             tbHtml += '<td>'+((tmpOpenNum == v) ? '<span class="cur">'+v+'':data.Records[i][tmp])+((tmpOpenNum == v) ? '</span>':'')+'</td>';
                         }
                    }
                    tbHtml += '</tr>';
                }
                //平均、最大遗漏
				
                var ylHtml = '<tr class="trend-bg-average"	>';
			ylHtml += '<td>平均遗漏</td>';
                if (data.iYLAvg0 != undefined) {
                    ylHtml += '<td>'+data.iYLAvg0+'</td>';
                }
                if (data.iYLAvg1 != undefined) {
                    ylHtml += '<td>'+data.iYLAvg1+'</td>';
                }
                ylHtml += '<td>'+data.iYLAvg2+'</td>';
                ylHtml += '<td>'+data.iYLAvg3+'</td>';
                ylHtml += '<td>'+data.iYLAvg4+'</td>';
                ylHtml += '<td>'+data.iYLAvg5+'</td>';
                ylHtml += '<td>'+data.iYLAvg6+'</td>';
                for(v=7;v<51;v++){
                	var num = 'iYLAvg'+v;
	                if (data[num] != undefined) {
	                    ylHtml += '<td>'+data[num]+'</td>';
	                }
                }
                ylHtml += '</tr>';
                ylHtml += '<tr>';
			ylHtml += '<td>最大遗漏</td>';
                if (data.iYLMax0 != undefined) {
                    ylHtml += '<td>'+data.iYLMax0+'</td>';
                }
                if (data.iYLMax1 != undefined) {
                    ylHtml += '<td>'+data.iYLMax1+'</td>';
                }
                ylHtml += '<td>'+data.iYLMax2+'</td>';
                ylHtml += '<td>'+data.iYLMax3+'</td>';
                ylHtml += '<td>'+data.iYLMax4+'</td>';
                ylHtml += '<td>'+data.iYLMax5+'</td>';
                ylHtml += '<td>'+data.iYLMax6+'</td>';
                for(v=7;v<51;v++){
                	var num1 = 'iYLMax'+v;
	                if (data[num1]!= undefined) {
	                    ylHtml += '<td>'+data[num1]+'</td>';
	                }
                }
                ylHtml += '</tr>';
                //清楚划线
                $('div#chartsDiv_1 canvas').remove();
                $('#trend_table_1').html(headHtml + tbHtml/*  + ylHtml */);
                $('#trend_js').html(ylHtml);
                
                //return;
                //先获取所有开奖号码对象，然后把每两个对象组成一个canvas
                var cvList = $('td span.cur');
                var cvHtml = '';
                for (var i = 0; i < cvList.length; i++) {
                    //alert('v:'+$(cvList[i]).width()+':'+$(cvList[i]).height());
                    if (i == 0) {
                        continue;
                    }
                    var tmpBallHalf = parseInt($(cvList[i]).width()/2);
                    var tmpHeight = $(cvList[i]).position().top - $(cvList[i-1]).position().top;
                    tmpHeight = Math.abs(parseInt(tmpHeight));
                    var tmpWidth = $(cvList[i]).position().left - $(cvList[i-1]).position().left;
                    var direc = (tmpWidth < 0) ? -1 : 1;
                    tmpWidth = Math.abs(parseInt(tmpWidth));
                    tmpWidth = (tmpWidth == 0) ? 1 : tmpWidth;
                    //left,top
                    var tmpTop = Math.min($(cvList[i]).position().top, $(cvList[i-1]).position().top);
                    var tmpLeft = Math.min($(cvList[i]).position().left, $(cvList[i-1]).position().left);
                    tmpTop = Math.abs(parseInt(tmpTop)) + parseInt(tmpBallHalf) + 10;
                    tmpLeft = Math.abs(parseInt(tmpLeft)) + parseInt(tmpBallHalf) - 1;
					cvHtml += '<canvas class="trend-canvas" style="position:absolute; z-index:2;visibility: visible; ' + 'border:0px solid;left:'+tmpLeft+'px;top:'+tmpTop+'px;" data-half="'+tmpBallHalf+'" data-direc_1="'+direc+'" width="'+tmpWidth+'" height="'+tmpHeight+'"></canvas>';
                }
               
			   
			   $('div#chartsDiv_1').append(cvHtml);
				
                drawLine(1);
                //loaded();
            }
        });
    }
</script> 	
{/block}
